package top.dbpanda.cmsjpa.learn.thread.juc;

import java.util.concurrent.PriorityBlockingQueue;

/**
 * @author 20018954
 */
public class TestBlockingQueue {
    public static void main(String[] args) throws InterruptedException {
        PriorityBlockingQueue<Myjob> myjobPriorityBlockingQueue = new PriorityBlockingQueue<>();
        myjobPriorityBlockingQueue.add(new Myjob(3));
        myjobPriorityBlockingQueue.add(new Myjob(2));
        myjobPriorityBlockingQueue.add(new Myjob(1));
        //优先级的排序规则 在第一次调用take()方法才生效
        System.out.println("队列：" + myjobPriorityBlockingQueue);
        System.out.println("取出队列中的一个元素：" + myjobPriorityBlockingQueue.take());
        System.out.println("容器：" + myjobPriorityBlockingQueue);
    }
}

